{include file="public/header" /}
<style>
    .login-list .flex-center {
        width: 27%;
        justify-content: right;
    }
    .register-agr{
        margin-top: 15px;
        display: block !important;
        padding: 0 !important;
    }
    .register-agr span a{
        display: contents !important;
    }
</style>
<body class="hide-top"  style="background-color: #fff">
<div class="login-container">
    <img src="/static/index/img/icon5.png" alt="">
    <div class="submit-content" style="padding-bottom:inherit">
        <div class="submit-hd flex-center" style="color: #000;position: fixed;width: 100%;z-index: 999;background-color: rgba(234,248,240)">
            <span class="layui-icon layui-icon-left" onclick="location.href='/index/login/index.html'"></span>注册账号
        </div>
    <div class="login-content register-content">
<!--        <p>您好，欢迎注册</p>-->
        <form action="{:url('register/save')}" method="post" class="form layui-form">
            <ul class="login-list">
                <li>
                    <p>编号</p>
                    <div>
                        <input type="text" name="code" placeholder="请填写会员编号">
                    </div>
                </li>
                <li>
                    <p>姓名</p>
                    <div>
                        <input type="text" name="nickname" placeholder="请填写姓名">
                    </div>
                </li>
                <li>
                    <p>手机号</p>
                    <div>
                        <input type="number" name="mobile" id="mobile" placeholder="请填写手机号">
                    </div>
                </li>
                {if $sys['is_sms'] == 1}
                <li>
                    <p>短信验证码</p>
                    <div>
                        <input type="text" name="captcha" placeholder="请输入短信验证码">
                        <span class="code">获取验证码</span>
                    </div>
                </li>
                {/if}
                <li>
                    <p>登录密码</p>
                    <div>
                        <input type="password" name="password" placeholder="请设置登录密码">
                    </div>
                </li>
                <li>
                    <p>确认登录密码</p>
                    <div>
                        <input type="password" name="password_confirm" placeholder="请设置登录密码">
                    </div>
                </li>
                <li>
                    <p>支付密码</p>
                    <div>
                        <input type="password" name="pay_password" placeholder="请设置支付密码">
                    </div>
                </li>
                <li>
                    <p>确认支付密码</p>
                    <div>
                        <input type="password" name="pay_password_confirm" placeholder="请设置支付密码">
                    </div>
                </li>
                <li>
                    <p>邀请人</p>
                    <div>
                        <input type="text" name="parent_code" id="parent_code" placeholder="请输入邀请人" {if $Request.param.code}value="{$Request.param.code}" readonly{/if}>
                    </div>
                </li>
                <!-- <li>
                    <p>系统标识</p>
                    <div>
                        <input type="text" name="tag" id="tag" placeholder="请输入" {if $Request.param.tag} value="{$Request.param.tag}" {/if} readonly>
                    </div>
                </li> -->
            </ul>
            <div class="register-agr">
                <input type="checkbox" name="agree" lay-skin="primary" value="1">我已阅读并同意，注册
                <span>
                <a href="{:url('index/communal')}?type=privacy_msg">《隐私政策》</a>
                <a href="{:url('index/communal')}?type=pact_msg">《志愿者公约》</a>
                <!-- <a href="{:url('index/communal')}?type=statute_msg">《计划章程》</a> -->
                <a href="{:url('index/communal')}?type=register_msg">《用户协议》</a>
                </span>
                
            </div>
        </form>

        <p class="save" lay-submit lay-filter="save" formObj=".form">注册</p>

    </div>
    </div>
</div>

</body>
{include file="public/footer"/}
<script>
 $('#parent_code').blur(function () {
        var value = $(this).val();
        if (value) {
            $.ajax({
                type: 'GET',
                url: '{:url("register/verify")}',
                data: {code: value},
                dataType: "json",
                success: function (data) {
                    if (data.code === 1) {
                        $("#tag").val(data.data).css('color', '#008200');
                    } else {
                        $("#tag").val(data.data).css('color', 'red');
                    }
                }
            });
        } else {
            $("#tag").val('');
        }
    });
</script>
<script>
    var os = true;
    var time = 60;
    $('.code').click(function () {
        var mobile = $('#mobile').val();
        if (!mobile) {
            layer.msg('请输入手机号');
            return false;
        }
        if (os !== true) return false;
        os = false;
        layer.load(2);
        $.ajax({
            type: "POST",
            url: "{:url('login/sendSms')}",
            data: {mobile: mobile, action: 'register'},
            success: function (data) {
                layer.closeAll();
                console.log(data);
                if (data.code == 1) {
                    layer.msg(data.msg, {time: 1500}, function () {
                        $('.code').html(time + 's');
                        time--;
                        $('.code').siblings();
                        let isTime = setInterval(() => {
                            if (time == 0) {
                                clearInterval(isTime);
                                time = 60;
                                $('.code').html('获取验证码');
                                os = true;
                            }else{
                                $('.code').html(time-- + 's')
                            }
                        }, 1000);
                    });
                } else {
                    os = true;
                    layer.msg(data.msg);
                }
            }
        });
    })
</script>
</html>